//双十一倒计时开始
function GetTime() {
    var EndTime = new Date('2021/11/11 00:00:00');
    var NowTime = new Date();
    var t = EndTime.getTime()-NowTime.getTime();
    var d = 0;
    var h = 0;
    var m = 0;
    var s = 0;
    if (t>0){
        d=Math.floor(t/1000/60/60/24)
        h=Math.floor(t/1000/60/60%24)
        m=Math.floor(t/100/60%60)
        s=Math.floor(t/1000%60)
    }
    document.getElementById('dayTime').innerHTML=d;
    document.getElementById('hourTime').innerHTML=h;
    document.getElementById('minTime').innerHTML=m;
    document.getElementById('secTime').innerHTML=s;
}
setInterval(GetTime,0)
//双十一倒计时结束
//基于jquery的轮播图开始
$(document).ready(function () {
    var i = 0;
    var timer;
    $('.item').eq(0).show().siblings('.item').hide();
    function show() {
       $('.item').eq(i).fadeIn(300).siblings('.item').fadeOut(300);
       $('.tab').eq(i).addClass('active').siblings('.tab').removeClass('active');
    }
    function showTime() {
        timer = setInterval(function(){
            show();
            i++;
            if(i==5){
                i = 0;
            }
        },3000)
    }
    showTime();

    $('.tab').hover(function () {
        i = $(this).index();
        show();
        clearInterval(timer);
    },function () {
        showTime();
    })

    $('.prev').click(function () {
        clearInterval(timer);
        if(i==0){
            i=5;
        }
        i--;
        show();
        showTime();
    });

    $('.next').click(function () {
        clearInterval(timer);
        if(i==4){
            i=-1;
        }
        i++;
        show();
        showTime();
    });
})
//基于jquery的轮播图结束
//抽奖开始
function CJ() {
    var number = document.getElementsByTagName('input');
    var luck = Math.floor(Math.random()*100+1);
    number[0].placeholder='恭喜您，获取了价值'+luck+'元代金券';
}
document.getElementById('cj').addEventListener('click',
    function (even) {
        CJ();
    }
)
//抽奖结束
//返回开始
$(document).ready(function () {
    $('#back').hide()

    $(function () {
        
        $(window).scroll(function () {
            if ($(window).scrollTop()>200){
                $('#back').fadeIn(200);
            }
            else{
                $('#back').fadeOut(200);
            }
        })

        $('#back').click(function () {
            $('body,html').animate({
                scrollTop:0
            },500);
            return false;
        })
    })
})
//返回结束